package com.ticket.sass.admin.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ticket.sass.common.entity.tenant.FilmEntity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author ywb
 * @since 2024-03-07
 */
public interface FilmMapper extends BaseMapper<FilmEntity> {
    @Select("""
        SELECT film.id, film.name, map.price_scheme_id
        FROM films film
        INNER JOIN price_scheme_film_maps map ON film.id = map.film_id
        WHERE map.price_scheme_id IN
        (${priceSchemeIds})
        AND map.deleted_at IS NULL
        AND film.deleted_at IS NULL
    """)
    List<FilmEntity> queryFilmsByPriceSchemeIds(@Param("priceSchemeIds") String priceSchemeIds);


    
    @Select("""
    SELECT film.id, film."name"
    FROM films film
    INNER JOIN coupon_film_maps map ON film.id = map.film_id
    WHERE map.coupon_id = #{couponId}
    AND map.deleted_at IS NULL
    AND film.deleted_at IS NULL
""")
    List<FilmEntity> queryFilmsByCouponId(@Param("couponId") Long couponId);

    
}
